package com.yimu.lib.util;

import android.content.Context;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.yimu.lib.R;
import com.yimu.lib.widget.transform.GlideCircleTransform;
import com.yimu.lib.widget.transform.GlideRoundTransform;
/**
 * 描述：图片加载框架
 * 创建者：  Churck
 * 创建时间：16/8/16 17:00
 * 修改者： Churck
 * 修改时间：16/8/16 17:00
 * 版 本：v1.0
 */
public class ThreeThimagLoading {
    public static void display(String url, ImageView imageView, Context context) {
        Glide.with(context)
                .load(url)
                .placeholder(R.drawable.default_image_banner)
                .error(R.drawable.default_image_banner)
                .override(480, 800)
                .into(imageView);
    }
    public static void displayRound(Context context,String url, ImageView imageView, int round) {
        Glide.with(context)
                .load(url)
                .placeholder(R.drawable.default_image_banner)
                .override(480, 800)
                .transform(new GlideRoundTransform(context,round))
                .error(R.drawable.default_image_banner)
                .into(imageView);

    }
    public static void displayCircle(final Context context, String url, final ImageView imageView) {
        Glide.with(context)
                .load(url)
                .asBitmap()
                .override(480, 800)
                .transform(new GlideCircleTransform(context))

                .placeholder(R.drawable.default_image_banner)
                .error(R.drawable.default_image_banner)
                .override(480, 800)
//                .centerCrop()
//                .crossFade()
                .into(imageView);

//               .into(new BitmapImageViewTarget(imageView) {
//            @Override
//            protected void setResource(Bitmap resource) {
//                RoundedBitmapDrawable circularBitmapDrawable =
//                        RoundedBitmapDrawableFactory.create(context.getResources(), resource);
//                circularBitmapDrawable.setCircular(true);
//                imageView.setImageDrawable(circularBitmapDrawable);
//            }
//        });
    }
    public static void display(Context context,String url, ImageView imageView, int options) {
        Glide.with(context)
                .load(url)
                .placeholder(options)
                .override(480, 800)
                .error(R.drawable.default_image_banner)
                .into(imageView);

    }





}
